package com.hy.convenient.api.controller.down;

import com.hy.convenient.api.controller.conInterface.DownControllerInterface;
import com.hy.convenient.api.pojo.PaymentPojo;
import com.hy.convenient.api.pojo.check.Check;
import com.hy.convenient.api.pojo.check.CheckUpdateCheckPojo;
import com.hy.convenient.api.server.PaymentServer;
import com.hy.convenient.common.LayuiToTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description TODO
 * @className PaymentController
 * @Author hdy
 * @Date 2021-1-7 16:52
 * @Version 1.0
 */
@RestController
public class PaymentController implements DownControllerInterface<Check> {

    @Autowired
    private PaymentServer paymentServer;
    @Override
    @PostMapping("/api/downPayment")
    public Map<String, Object> downData(@RequestBody Check t) {
        String str = check(t);
//        if (!StringUtils.isEmpty(str)) {
//            return LayuiToTable.business_fail(str);
//        }
//        if (!MD5.check(t.getMerId() + t.getCwbm()+t.getDateTime(), t.getSign())) {
//            return LayuiToTable.business_fail("签名失败");
//        }
        if (t.getPage() == 0) {
            t.setPage(1);
        }
        Map<String, Object> map = new HashMap();
        map.put("merId", t.getMerId());
//        改状态写死 用于下发生效的支付方式
        map.put("rState", 1);
        map.put("pageSize", t.getPageSize());
        map.put("starSize", (t.getPage() - 1) * t.getPageSize());
        int count = paymentServer.queryCount(map);
        List<PaymentPojo> list = paymentServer.queryDownList(map);
        return LayuiToTable.business_suf(list, count);
    }

    @Override
    public Map<String, Object> checkUpdateDateDown(CheckUpdateCheckPojo t) {
        return null;
    }
}
